package com.gitee.gateway.beans;

import com.gitee.gateway.core.db.Modal;
import io.vertx.codegen.annotations.DataObject;
import io.vertx.core.json.JsonObject;

@DataObject
public class DemoBean extends Modal<DemoBean> {

    private String name;
    private int age;

    public DemoBean() {
    }

    /**
     * 此方法是 @DataObject 要求的，用于将 JsonObject 转换为 JavaBean
     *
     * @param json
     */
    public DemoBean(JsonObject json) {
        this.id = json.getLong("id", 0l);
        this.name = json.getString("name");
        this.age = json.getInteger("age", 0);
    }

    /**
     * 此方法是 @DataObject 要求的，用于将 JavaBean 转换为 JsonObject
     *
     * @return
     */
    public JsonObject toJson() {
        return JsonObject.mapFrom(this);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}
